# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt

import matplotlib
matplotlib.rcParams['mathtext.fontset'] = 'stix'
matplotlib.rcParams['font.family'] = 'STIXGeneral'


#%% FONCTION
fq = 440
S = 1

def s(t,f,s,phi=0):
    
    return s*np.sin(2*np.pi*f*t+phi)


#LISTE DES X
t = np.linspace(0,0.1,10) #début, fin, nombre de points
t2= np.linspace(0,0.1,100)
t3 = np.linspace(0,0.1,1000)

#LISTE DES Y
Y1 = s(t, fq, s=S)
Y2 = s(t2, fq, s=S)
Y3 = s(t3, fq, s=S)


#%% GRAPHE

fig = plt.figure(figsize=(12,6))
ax = fig.add_subplot(311)
ax2 = fig.add_subplot(312)
ax3 = fig.add_subplot(313)

ax.set_xlim(0,0.1) #Limites de l'axe X
ax.set_ylim(-2,2) #Limites de l'axe Y

ax2.set_xlim(0,0.1) #Limites de l'axe X
ax2.set_ylim(-2,2) #Limites de l'axe Y

ax3.set_xlim(0,0.1) #Limites de l'axe X
ax3.set_ylim(-2,2)

ax.set_xlabel(r'$t$', fontsize = 20) #Titre axe X
ax.set_ylabel(r'$S(t)$', fontsize = 20) #Titre axe Y

ax2.set_xlabel(r'$t$', fontsize = 20) #Titre axe X
ax2.set_ylabel(r'$S(t)$', fontsize = 20) #Titre axe Y

ax3.set_xlabel(r'$t$', fontsize = 20) #Titre axe X
ax3.set_ylabel(r'$S(t)$', fontsize = 20) #Titre axe Y


ax.plot(t,Y1,'o', label='$Te=10^{-2}s$', lw=2.5) #label : nom dans la légende, lw : épaisseur du trait

ax2.plot(t2,Y2,'o', label='$Te = 10^{-3}s$', lw=2.5) 

ax3.plot(t3,Y3,'o', label='$Te = 10^{-4}s$', lw=2.5) 



# %% ANALOGIQUE

ax.plot(t3,Y3, '--r', zorder=0, alpha = 0.5)#alpha) coef de transparence 
ax2.plot(t3,Y3, '--r', zorder=0, alpha = 0.5)#alpha) coef de transparence 
ax3.plot(t3,Y3, '--r', zorder=0, alpha = 0.5)#alpha) coef de transparence 


#%% OPTIONNEL

ax.grid(True) #Grille
ax.legend(loc=2 ,prop={'size':15}) #Legende
ax2.legend(loc=2 ,prop={'size':15}) #Legende
ax3.legend(loc=2 ,prop={'size':15}) #Legende
ax2.grid(True) #Grille
ax3.grid(True) #Grille




